//
// CTriangle.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CPlane;
import org.ryzom.nel.misc.CVector;

public class CTriangle {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CTriangle(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CTriangle obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CTriangle(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setV0(CVector value) {
    nel3dJNI.CTriangle_V0_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getV0() {
    return new CVector(nel3dJNI.CTriangle_V0_get(swigCPtr, this), true);
  }

  public void setV1(CVector value) {
    nel3dJNI.CTriangle_V1_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getV1() {
    return new CVector(nel3dJNI.CTriangle_V1_get(swigCPtr, this), true);
  }

  public void setV2(CVector value) {
    nel3dJNI.CTriangle_V2_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getV2() {
    return new CVector(nel3dJNI.CTriangle_V2_get(swigCPtr, this), true);
  }

  public CTriangle() {
    this(nel3dJNI.new_CTriangle__SWIG_0(), true);
  }

  public CTriangle(CVector a, CVector b, CVector c) {
    this(nel3dJNI.new_CTriangle__SWIG_1(CVector.getCPtr(a), a, CVector.getCPtr(b), b, CVector.getCPtr(c), c), true);
  }

  public boolean intersect(CVector p0, CVector p1, CVector hit, CPlane plane) {
    return nel3dJNI.CTriangle_intersect(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(p1), p1, CVector.getCPtr(hit), hit, CPlane.getCPtr(plane), plane);
  }

  public void computeGradient(float c0, float c1, float c2, CVector grad) {
    nel3dJNI.CTriangle_computeGradient(swigCPtr, this, c0, c1, c2, CVector.getCPtr(grad), grad);
  }

  public void applyMatrix(SWIGTYPE_p_NLMISC__CMatrix m, CTriangle dest) {
    nel3dJNI.CTriangle_applyMatrix(swigCPtr, this, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(m), CTriangle.getCPtr(dest), dest);
  }

  public void getMinCorner(CVector dest) {
    nel3dJNI.CTriangle_getMinCorner(swigCPtr, this, CVector.getCPtr(dest), dest);
  }

  public void getMaxCorner(CVector dest) {
    nel3dJNI.CTriangle_getMaxCorner(swigCPtr, this, CVector.getCPtr(dest), dest);
  }

}
